package com.ifast.check.entity;

import com.alibaba.fastjson.JSON;
import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
public class CheckEntity implements Serializable {

    String name;
    String type;
    String cron;
    String[] hosts;
    Integer groupId;

    public CheckEntity() {

    }

    public CheckEntity(String str) {

        HashMap hashMap = JSON.parseObject(str, HashMap.class);
        name = hashMap.get("name").toString();
        type = hashMap.get("type").toString();
        try {
            cron = hashMap.get("cron").toString();
        } catch (Exception e) {

        }
        hosts = new String[]{hashMap.get("hosts").toString().replaceAll("\"", "")
                .replace("[", "").replace("]", "")};

    }
}
